<?php #//v.3.3.0
#///////////////////////////////////////////////////////
#//  COPYRIGHT 2004 Phpauction.org ALL RIGHTS RESERVED//
#///////////////////////////////////////////////////////

require('./includes/config.inc.php');
  
  
  
       
    
    
     $TIME = mktime(date("H")+$SETTINGS['timecorrection'],date("i"),date("s"),date("m"), date("d"),date("Y"));

$NOW = date("YmdHis",$TIME);
  
$query = "select * from PHPAUCTIONXL_auctions WHERE closed='0' AND suspended='0' AND starts<='$NOW' order by id";
$result = mysql_query($query);
$num_auction = mysql_num_rows($result);



 $i = 0;
while($i < $num_auction) {
  
  $auction_id = mysql_result($result,$i,"id");
                   
// Get Auction ID


    $jsenddate = " ";
    $jsenddate .= "|";
    $jsenddate .= "A";
      /*
$id2 = $_SESSION["PHPAUCTION_LOGGED_IN"];
 
 if($id2) {
 
  $query = mysql_fetch_array(mysql_query("SELECT bids_remaining FROM PHPAUCTIONXL_users WHERE id=$id2 "));
  
  $jsenddate = " ";
  $jsenddate .= "|";
  $jsenddate .= $query['bids_remaining'];
   
  }
         if(!$id2) {
  
  $jsenddate = " ";   
  $jsenddate .= "|";
    $jsenddate .= "A";
  
  }
           */
           
$jsenddate .= "|";
  
// Create DATE & TIME


$jsenddate .= substr ($NOW, 4, 2);
$jsenddate .= "/";
$jsenddate .= substr ($NOW, 6, 2);
$jsenddate .= "/";
$jsenddate .= substr ($NOW, 0, 4);
$jsenddate .= " ";



     
if (substr ($NOW, 8, 2) > 12) {
$jsenddate .= substr ($NOW, 8, 2)-12;
$jsampm = "PM";
}
if (substr ($NOW, 8, 2) != 00){
if (substr ($NOW, 8, 2) < 12) {
$jsenddate .= substr ($NOW, 8, 2);
$jsampm = "AM";
}}
if (substr ($NOW, 8, 2) == 12) {
$jsenddate .= substr ($NOW, 8, 2);
$jsampm = "PM";
}
if (substr ($NOW, 8, 2) == 00) {
$jsenddate .= 12;
$jsampm = "AM";
}



$jsenddate .= ":";
$jsenddate .= substr ($NOW, 10, 2);
$jsenddate .= ":";
$jsenddate .= substr ($NOW, 12, 2);
$jsenddate .= " ";
$jsenddate .= $jsampm;
$jsenddate .= "|";


//GET END TIME


           $reserve_price2 = mysql_result($result,$i,"reserve_price");
             $end_time = mysql_result($result,$i,"ends");
            $start_time  = mysql_result($result,$i,"starts");
      
  if ( $start_time < $NOW ) {
  
$jsenddate .= substr ($end_time, 4, 2);
$jsenddate .= "/";
$jsenddate .= substr ($end_time, 6, 2);
$jsenddate .= "/";
$jsenddate .= substr ($end_time, 0, 4);
$jsenddate .= " ";



     
if (substr ($end_time, 8, 2) > 12) {
$jsenddate .= substr ($end_time, 8, 2)-12;
$jsampm = "PM";
}
if (substr ($end_time, 8, 2) != 00){
if (substr ($end_time, 8, 2) < 12) {
$jsenddate .= substr ($end_time, 8, 2);
$jsampm = "AM";
}}
if (substr ($end_time, 8, 2) == 12) {
$jsenddate .= substr ($end_time, 8, 2);
$jsampm = "PM";
}
if (substr ($end_time, 8, 2) == 00) {
$jsenddate .= 12;
$jsampm = "AM";
}



$jsenddate .= ":";
$jsenddate .= substr ($end_time, 10, 2);
$jsenddate .= ":";
$jsenddate .= substr ($end_time, 12, 2);
$jsenddate .= " ";
$jsenddate .= $jsampm;
$jsenddate .= "|";
           
             }
           
          if ( $start_time > $NOW ) {
  
$jsenddate .= substr ($start_time, 4, 2);
$jsenddate .= "/";
$jsenddate .= substr ($start_time, 6, 2);
$jsenddate .= "/";
$jsenddate .= substr ($start_time, 0, 4);
$jsenddate .= " ";



     
if (substr ($end_time, 8, 2) > 12) {
$jsenddate .= substr ($start_time, 8, 2)-12;
$jsampm = "PM";
}
if (substr ($end_time, 8, 2) != 00){
if (substr ($end_time, 8, 2) < 12) {
$jsenddate .= substr ($start_time, 8, 2);
$jsampm = "AM";
}}
if (substr ($end_time, 8, 2) == 12) {
$jsenddate .= substr ($start_time, 8, 2);
$jsampm = "PM";
}
if (substr ($end_time, 8, 2) == 00) {
$jsenddate .= 12;
$jsampm = "AM";
}



$jsenddate .= ":";
$jsenddate .= substr ($start_time, 10, 2);
$jsenddate .= ":";
$jsenddate .= substr ($start_time, 12, 2);
$jsenddate .= " ";
$jsenddate .= $jsampm;
$jsenddate .= "|";
           
             }   
           
           
 $jsenddate .= $reserve_price2;
$jsenddate .= "|";


// GET COUNTER

$query2 = "SELECT counter as counter from PHPAUCTIONXL_auccounter where auction_id=$auction_id";
$result2 = mysql_query($query2);
$num_auction2 = mysql_num_rows($result2);

 $ii = 0;
while($ii < $num_auction2) {

  $counter = mysql_result($result2,$ii,"counter");

$jsenddate .= $counter;
$jsenddate .= "|";

$ii++;
}





// GET HIGH BIDDER INFO

             
  $high_bidder 	= mysql_result($result,$i,"current_high_bidder");
$high_bid 	= mysql_result($result,$i,"current_bid");


$jsenddate .= $high_bidder;
$jsenddate .= "|";
$jsenddate .= print_money_nosymbol($high_bid);
$jsenddate .= "|";




// GET # of BIDS
     /*

$query = "select * from PHPAUCTIONXL_bids where auction=$auction_id ORDER BY bid DESC";
$result_numbids = mysql_query ($query);
$num_auction2 = mysql_num_rows($result_numbids);

 $iiiiiiii=0;
 $ii = 0;
             
while($ii < $num_auction2) {

    $high_bidder 	= mysql_result($result_numbids,$ii,"current_high_bidder");
  
  if ( $ii > 0 ) { 
  $iii = $ii - 1;
  $high_bidder2 	= mysql_result($result_numbids,$iii,"current_high_bidder");
  }
$high_bid 	= mysql_result($result_numbids,$ii,"bid");
$ends_date = mysql_result($result_numbids,$ii,"bidwhen");
$auction_id = mysql_result($result_numbids,$ii,"auction");
     
   //$high_bidder2 	= mysql_result($result_numbids,$iii,"current_high_bidder"); 
    
    if ( $high_bidder2 != $high_bidder ) {
    

          $iiiiiiii++;


}
     $ii++;
}

 //echo $iiiiiiii;
$jsenddate .= $iiiiiiii;
$jsenddate .= "|";
*/


$iiiiiiii = $high_bid / .01;
$jsenddate .= $iiiiiiii;
$jsenddate .= "|";


// GET BID HISTORY





                 


$query222 = "select * from PHPAUCTIONXL_bids where auction=$auction_id ORDER BY id DESC LIMIT 0,8";
$result_numbids222 = mysql_query ($query222);
$num_auction222 = mysql_num_rows($result_numbids222);
       
       
        if ( $num_auction222 > 0 ){
            
 $iii = 0;
while($iii < $num_auction222) {


$high_bidder 	= mysql_result($result_numbids222,$iii,"current_high_bidder");
$high_bid 	= mysql_result($result_numbids222,$iii,"bid");
$ends = mysql_result($result_numbids222,$iii,"bidwhen");
   $proxy = mysql_result($result_numbids222,$iii,"accounttype");
    if ( $iii > 0 ) { 
  $iiii = $iii - 1;
  $high_bidder2 	= mysql_result($result_numbids222,$iiii,"current_high_bidder");
  }

  if ( $iii == 0)
  {
     $high_bidder2 	= mysql_result($result_numbids222,$iii,"current_high_bidder");
  }
        if ( $high_bidder2 != $high_bidder ) {
        
        
        if ( $proxy == "proxy" ) {
            $jsenddate .= "<font color=red>*</font>";
        }
        
$jsenddate .= $high_bidder;
$jsenddate .= "|";
$jsenddate .= print_money_nosymbol($high_bid);
$jsenddate .= "|";
$jsenddate .= substr ($ends, 4, 2);
$jsenddate .= "/";
$jsenddate .= substr ($ends, 6, 2);
$jsenddate .= "/";
$jsenddate .= substr ($ends, 2, 2);
$jsenddate .= " ";



if (substr ($ends, 8, 2) > 12) {
$jsenddate .= substr ($ends, 8, 2)-12;
$jsampm = "PM";
}
if (substr ($ends, 8, 2) != 00) {
if (substr ($ends, 8, 2) < 12) {
$jsenddate .= substr ($ends, 8, 2);
$jsampm = "AM";
}
}
if (substr ($ends, 8, 2) == 12) {
$jsenddate .= substr ($ends, 8, 2);
$jsampm = "PM";
}
if (substr ($ends, 8, 2) == 00) {
$jsenddate .= substr ($ends, 8, 2);
$jsampm = "AM";
}


$jsenddate .= ":";
$jsenddate .= substr ($ends, 10, 2);
$jsenddate .= ":";
$jsenddate .= substr ($ends, 12, 2);
$jsenddate .= " ";
$jsenddate .= $jsampm;
$jsenddate .= "|";

$iii++;

}

  if ( $iii == 0 ) {
        
           if ( $proxy == "proxy" ) {
            $jsenddate .= "<font color=red>*</font>";
        }
        
$jsenddate .= $high_bidder;
$jsenddate .= "|";
$jsenddate .= print_money_nosymbol($high_bid);
$jsenddate .= "|";
$jsenddate .= substr ($ends, 4, 2);
$jsenddate .= "/";
$jsenddate .= substr ($ends, 6, 2);
$jsenddate .= "/";
$jsenddate .= substr ($ends, 2, 2);
$jsenddate .= " ";



if (substr ($ends, 8, 2) > 12) {
$jsenddate .= substr ($ends, 8, 2)-12;
$jsampm = "PM";
}
if (substr ($ends, 8, 2) != 00) {
if (substr ($ends, 8, 2) < 12) {
$jsenddate .= substr ($ends, 8, 2);
$jsampm = "AM";
}
}
if (substr ($ends, 8, 2) == 12) {
$jsenddate .= substr ($ends, 8, 2);
$jsampm = "PM";
}
if (substr ($ends, 8, 2) == 00) {
$jsenddate .= substr ($ends, 8, 2);
$jsampm = "AM";
}


$jsenddate .= ":";
$jsenddate .= substr ($ends, 10, 2);
$jsenddate .= ":";
$jsenddate .= substr ($ends, 12, 2);
$jsenddate .= " ";
$jsenddate .= $jsampm;
$jsenddate .= "|";

$iii++;

}

   }
    }         

    if($num_auction2 < 1 ){
    
$jsenddate .= "--|--|--|--|--|--|--|--|--|--|--|--|--|--|--|";    
    }

      if( $num_auction2 < 2 ){
    
$jsenddate .= "--|--|--|--|--|--|--|--|--|--|--|--|";    
    }
    
       if( $num_auction2 < 3 ){
    
$jsenddate .= "--|--|--|--|--|--|--|--|--|";    
    }


           if( $num_auction2 < 4 ){
    
$jsenddate .= "--|--|--|--|--|--|";    
    }
    
            if( $num_auction2 < 5 ){
    
$jsenddate .= "--|--|--|";    
    }  
    
   /* 
   $query_settings = "select * from PHPAUCTIONXL_proxybid_settings where id='1'";
                             $query_settings2a =  mysql_query ($query_settings);
                                $activated = mysql_result($query_settings2a,0,"activated");
                                
                                 
        if ( $activated == 1 ) {
    if ( $_SESSION["PHPAUCTION_LOGGED_IN"] ) {
 
 
  $query444 = mysql_fetch_array(mysql_query("SELECT proxybidqty FROM PHPAUCTIONXL_proxybid WHERE itemid=$auction_id AND userid=$id2 "));
  

 $autobidder_bids_remaining = $query444['proxybidqty'];
 
 $jsenddate .= $autobidder_bids_remaining;
  
 }
       if ( !$_SESSION["PHPAUCTION_LOGGED_IN"] ) {
             $jsenddate .= login;  
       }
       
  } 
       if ( $activated == 0 ) {
       
       
                  $jsenddate .= login; 
    
             }
             
             */
             
             
$myFile = "cronfiles/item_page_ajax";
$myFile .= $auction_id;
$myFile .= ".txt";  
    
if ( (substr(sprintf("%o",fileperms($myFile)),-4)) != 0777 ) {

 chmod($myFile,0777);
} 

echo substr(sprintf("%o",fileperms($myFile)),-4); 
$fh = fopen($myFile, 'w') or die("can't open file");
$stringData = $jsenddate;
fwrite($fh, $stringData);
fclose($fh);

  echo $myFile;

    
$i++;
}

  

?>





